#ifndef SERVER_SERVER_TEMPLATE_H
#define SERVER_SERVER_TEMPLATE_H

#include <muduo/net/TcpServer.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpConnection.h>

#include <memory>

class AbstractAdderFactory;
class Server {
private:
    void onConnection(const muduo::net::TcpConnectionPtr& conn);
    void onMessage(const muduo::net::TcpConnectionPtr& conn,
                            muduo::net::Buffer* buf, muduo::Timestamp time);
    
public:
    Server(muduo::net::EventLoop* loop, const muduo::net::InetAddress& listenAddr);
    void start() { server_.start(); }
private:
    muduo::net::EventLoop* loop_;
    muduo::net::TcpServer server_;
    std::shared_ptr<AbstractAdderFactory> factory_;
};

#endif